import { ref } from 'vue'
import {getId} from '../utils/config'
export default function newTodo(todoList) {
    const todoTitle = ref('');
    let addTodo = () => {
        let result = todoTitle.value.trim();
        if (!result) {
            return
        }
        let value = {
            id:getId(),
            completed:false,
            title:result
        }
        todoList.value.push(value);
        todoTitle.value = '';
    }
    return {
        todoTitle,
        addTodo
    }
}